package com.cyx.exam.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cyx.exam.entity.Class;
import com.cyx.exam.entity.Exam;
import com.cyx.exam.mapper.ExamMapper;
import com.cyx.exam.service.ExamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyx.exam.service.QuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 课程 服务实现类
 * </p>
 *
 * @author cyx
 * @since 2021-03-09
 */
@Service
public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements ExamService {
    @Resource
    private ExamMapper examMapper;

    @Override
    public IPage<Exam> selectByPage(int start, int size) {
        Page<Exam> page=new Page<>(start,size);
        examMapper.selectPage(page, null);
        return page;
    }

    @Override
    public IPage<Exam> searchByPage(int start, int size, String name) {
        Page<Exam> page=new Page<>(start,size);
        examMapper.selectPage(page, new QueryWrapper<Exam>().like("title", "%"+name+"%"));
        return page;
    }

    @Override
    public int delete(Integer id) {
        QueryWrapper<Exam> wrapper = new QueryWrapper<Exam>();
        wrapper.eq("id",id);
        return examMapper.delete(wrapper);
    }

    @Override
    public int score(Integer id) {
        return examMapper.score(id);
    }
}
